package com.example.dem4;

public class People2 implements Runnable {
    private BankCard bankCard;

    public People2(BankCard bankCard) {
        this.bankCard = bankCard;
    }
    @Override
    public void run(){
        for (int i =0;i<10;i++){
            if (bankCard.getBalance()>=1000){
                bankCard.setBalance(bankCard.getBalance()-1000);
                System.out.println(Thread.currentThread().getName()+"向卡中取出1000,卡中余额"+bankCard.getBalance());
            }else {
                System.out.println("余额不足,请存钱");
                i--;
            }
        }
    }
}
